import plugin from '../../../lib/plugins/plugin.js'
import { Config } from '../components/index.js'
export class groupAdd extends plugin {
  constructor () {
    super({
      name: '小月加群请求',
      dsc: '加群请求',
      event: 'request.group.add',
    })
  }

  async accept () {
  let qg = Config.xyss
  if (!qg.qg) return
	let config =  Config.xyqg
  if (config.blackList.includes(this.e.user_id)) {
    await this.e.approve(false)
    return
  } else if (config.whileList.includes(this.e.user_id)) {
    await this.e.approve(true)
    return
  }
    let msg = ['接收到一个新的加群请求\n',
      `QQ：${this.e.user_id}\n`,
      `昵称：${this.e.nickname}\n`,
	  `请求码：${this.e.seq}\n`
    ]
    msg.push(`${this.e.comment}`)
    if (this.e.inviter_id)  msg.push(`\n邀请人：${this.e.inviter_id}`)	
    await Bot.pickGroup(this.e.group_id).sendMsg(msg)
  }
}